#pragma once
#include "base_file.h"
#include <QTextCodec>

BaseFile::BaseFile(const QString fileName, QObject* parent)
{
    m_fileName = fileName;
}

BaseFile::BaseFile(QObject* parent)
{

}

const QString BaseFile::fileName()
{
    return m_fileName;
}

void BaseFile::setFileName(const QString fileName)
{
    m_fileName = fileName;
}

bool BaseFile::openFile(QFile::OpenMode flags)
{
    m_file.setFileName(m_fileName);
    if (!m_file.open(flags)) {
        qDebug() << QString("file(%1) open failed.").arg(m_fileName);
        return false;
    }

    return true;
}

void BaseFile::closeFile()
{
    m_file.close();
}

void BaseFile::writeFile(const QString& inData)
{
    m_file.write(inData.toUtf8());
};

void BaseFile::readFile(QString& outData)
{
    outData = m_file.readAll();
};
